import java.util.Stack;

public class Solution {

    Stack<Integer> stack = new Stack<>(); 
    Stack<Integer> minStack = new Stack<>(); //辅助栈
    public void push(int node) {
        stack.push(node);
        if(minStack.empty()){
            minStack.push(node);
        }
        //辅助栈不为空时，判断node和栈顶元素大小，如果比当前栈顶小则入栈
        if(node <= minStack.peek()){
            minStack.push(node);
        }
    }
    
    //弹出栈顶元素
    public void pop() {
        if(stack.pop() == minStack.peek()){
            minStack.pop();
        }
    }
    
    //拿到栈顶元素不弹出
    public int top(){
        return stack.peek();
    }
    
    public int min(){
        return minStack.peek();
    }
}